package com.example.securityconfig.controller;


import com.example.securityconfig.entity.Result;
import com.example.securityconfig.entity.User;
import com.example.securityconfig.service.Impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HXB
 * @since 2024-01-07
 */
@RestController
@RequestMapping("/user")
public class UserController{

    @Autowired
    private UserServiceImpl userServiceImpl;

    @PostMapping ("/login")
    public Result<?> login(@RequestBody User loginVo){
        return userServiceImpl.loginUser(loginVo);
    }

    @GetMapping("/userDate")
    public Result<?> userDate(@RequestParam Long id){
        return userServiceImpl.getUserData(id);
    }

    @GetMapping("/logout")
    public Result<?> logout(@RequestHeader String token){
        return userServiceImpl.logout(token);
    }

    @PostMapping("/manage/addUser")
    public Result<?> addUser(@RequestBody User user,@RequestParam Long id){
        return userServiceImpl.addUser(user,id);
    }
}

